﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataControl;
using System.Data;
using System.Text;

namespace ATW.MT.BUS
{
    public class bus_C_Design
    {
        DataAccess da = null;
        public bus_C_Design()
        {
            da = new DataAccess();
        }
        #region 方法
        /// <summary>
        /// 设计分页查询
        /// </summary>
        /// <param name="name"></param>
        /// <param name="page"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public DataTable DesignPagerQuery(string name, int page, int pagesize)
        {
            StringBuilder sql = new StringBuilder();
            sql.Append("select * from C_DesignLevel where rowstatus<>'2'");
            if (!String.IsNullOrEmpty(name))
            {
                sql.Append(" and [desc] like '%" + name + "%'");
            }
            return da.PageSize(sql.ToString(), page, pagesize, "DesignLevelID","create_time desc");
        }
        /// <summary>
        /// 新增设计等级
        /// </summary>
        /// <param name="Desc"></param>
        /// <returns></returns>
        public int DesignAdd(string Desc)
        {
            string sql = "insert into C_DesignLevel([desc]) values('" + Desc + "')";
            return da.ExcuteNoQuery(sql.ToString());
        }
        /// <summary>
        /// 修改设计等级
        /// </summary>
        /// <param name="desc"></param>
        /// <param name="Did"></param>
        /// <returns></returns>
        public int DesignEdit(string desc, string Did)
        {
            string sql = "update C_DesignLevel set [desc] ='" + desc + "' where DesignLevelID ='" + Did + "'";
            return da.ExcuteNoQuery(sql.ToString());
        }
        /// <summary>
        /// 设计标准是否存在
        /// </summary>
        /// <param name="desc"></param>
        /// <returns></returns>
        public bool isDesignExist(string desc)
        {
            string sql = "select * from C_DesignLevel where [desc]='" + desc + "'";
            DataTable dt = da.ExecuteDataTable(sql.ToString());
            if (dt != null && dt.Rows.Count > 0)
            {
                return true;
            }
            return false;
        }
        #endregion
    }
}